{% extends "forum/manage/main.html" %}
{% load parseperm %}
{% block configures %}
<div id="manage_boards_menu">
    <span id="manage_boards_title">版块管理</span>
    <span id="manage_boards_toplinks">
    {% spaceless %}
    <a href="" id="mng_board_addbd">新增版块</a>
    |
    <a href="" id="mng_board_addbdct">新增分类</a>
    {% endspaceless %}
    </span>
</div>
<div id='mng_board_forms'>
    <form id='mng_add_board' action="{% url 'board_manage' action='add' id='0' %}" method="post">
        {% csrf_token %}
        <p>
            <span>
                <label for="bd_name">英文名称</label>
                <input type="text" name="name" id="bd_name" value="" />
            </span>
            <span>
                <label for="bd_showname">中文名称</label>
                <input type="text" name="showname" id="bd_showname" value="" />
            </span>
        </p>
        <p>
            <label for="bd_discription">版块简介</label>
            <input type="text" name="discription" id="bd_discription" value="" />
        </p>
        <p>
            <label for="bd_category">版块分类</label>
            <select name="category" id="bd_category">
                {% for category in categories %}
                <option value={{ category.id }}>{{ category.name }}</option>
                {% endfor %}
            </select>
        </p>
        <p>
            限制访问
            <input type="radio" name="restrict" id="bd_restrict_no" value=0 checked="checked" />否
            <input type="radio" name="restrict" id="bd_restrict_yes" value=1 />是
        </p>
        <p>
            <input type="submit" value="新建版块" />
        </p>
    </form>
    <form id='mng_add_board_category' action="{% url 'boardcategory_manage' action='add' id='0' %}" method="post">
        {% csrf_token %}
        <p>
            <span>
                <label for="bd_name">英文名称</label>
                <input type="text" name="name" id="bd_name" value="" />
            </span>
            <span>
                <label for="bd_showname">中文名称</label>
                <input type="text" name="showname" id="bd_showname" value="" />
            </span>
        </p>
        <p>
            <label for="bd_discription">分类简介</label>
            <input type="text" name="discription" id="bd_discription" value="" />
        </p>
        <p>
            <input type="submit" value="新建版块分类" />
        </p>
    </form>
</div>
{% regroup boards|dictsort:"category_id" by category as category_list %}
{% for category in category_list %}
<table class="manage_boards_catelist">
    <caption>{{ category.grouper.showname }}</caption>
    <thead>
        <tr>
            <th class="manage_boards_id">编号</th>
            <th class="manage_boards_name">英文名</th>
            <th class="manage_boards_showname">显示名称</th>
            <th class="manage_boards_restrict">访问限制</th>
            <th class="manage_boards_gperm">游客权限</th>
            <th class="manage_boards_uperm">用户权限</th>
            <th class="manage_boards_aperm">版主权限</th>
            <th class="manage_boards_operate">操作</th>
        </tr>
    </thead>
    <tbody>
        {% for board in category.list  %}
        <tr class="{% cycle "mng_users_trbga" "mng_users_trbgb" %}" >
            <td class="manage_boards_id">{{ board.id }}</td>
            <td class="manage_boards_name">{{ board.name }}</td>
            <td class="manage_boards_showname">{{ board.showname }}</td>
            <td class="manage_boards_restrict">{{ board.restrict|yesno:"是,否" }}</td>
            <td class="manage_boards_gperm"><a class="manage_boards_perm_link" href="{% url 'board_manage_perm' id=board.id perm_str=board.anonymous_perm %}">{{ board.anonymous_perm|parseperm|default:"(无)" }}</a></td>
            <td class="manage_boards_uperm"><a class="manage_boards_perm_link" href="{% url 'board_manage_perm' id=board.id perm_str=board.user_perm %}">{{ board.user_perm|parseperm|default:"(无)" }}</a></td>
            <td class="manage_boards_aperm"><a class="manage_boards_perm_link" href="{% url 'board_manage_perm' id=board.id perm_str=board.admin_perm %}">{{ board.admin_perm|parseperm|default:"(无)" }}</a></td>
            <td class="manage_boards_operate">简介|<a class="manage_boards_edit" href="{% url 'board_manage' id=board.id action='update' %}">编辑</a>|用户|删除</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endfor %}
{% endblock configures %}
